package com.tunan.lsj.business.card.web;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.github.pagehelper.EasyUiPage;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.tunan.lsj.business.card.service.CardService;
import com.tunan.persistence.model.GgDjbYw;
import com.tunan.system.web.BaseController;
@Controller
@RequestMapping(value = "/Card")
public class CardController extends BaseController {
	
	private Logger log = Logger.getLogger(CardController.class);
	@Autowired
	private CardService cardService;
	/**
	 * 暂住证列表
	 */
	@RequestMapping(value = "/showList", method = RequestMethod.GET)
	public ModelAndView townList() {
		return new ModelAndView("/lsj/card/card-list");
	}
	
	
	
	/**
	 * 查询暂住证
	 * 
	 * @return
	 */
	@RequestMapping(value = "/search", method = RequestMethod.POST)
	@ResponseBody
	public EasyUiPage search(@ModelAttribute("pageParams") Page pageParams,GgDjbYw wfds) {
		PageHelper.startPage(pageParams.getPageNum(), pageParams.getPageSize());
		Map<String,Object> params = new HashMap<String,Object>();
		params.put("xzq", wfds.getXzq());
		params.put("jz", wfds.getJz());
		params.put("jwh", wfds.getJwh());
		params.put("zzzh", wfds.getZzzh());
		params.put("jddm", wfds.getJddm());
		params.put("zhid", wfds.getZhid());
		params.put("fhid", wfds.getFhid());
		params.put("xm", wfds.getXm());
		params.put("zjhm", wfds.getZjhm());
		params.put("xb", wfds.getXb());
		params.put("dz", wfds.getDz());
		params.put("qfrq", wfds.getQfrq());
		params.put("yxqx", wfds.getYxqx());
		//params.put("sfgq", wfds.getSfgq());
		params.put("yxjzrq", wfds.getYxjzrq());
		params.put("sfzx", wfds.getSfzx());
		Page pageresult = (Page) cardService.selectAll(params);
		return pageresult.getEasyUiPage();
	}
	
	
	
	/**
	 * 进入详细信息界面
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/showDetail", method = RequestMethod.GET)
	public ModelAndView showModify(String ywlsh){
		ModelAndView model = new ModelAndView();
		try {
			if(StringUtils.isNotBlank(ywlsh)){
				GgDjbYw form = cardService.selectOne(ywlsh);
				model.addObject("vo",form);
			}
		} catch (Exception e) {
			log.error(e.getMessage(), e);
		}
		model.setViewName("/lsj/card/card-Detail");
		return model;
	}
	
	
	
}
